Skip to content

Add support for output_files#618

Merged
niknetniko merged 24 commits intofiles-featuresfrom
output-files
Mar 5, 2026
Merged

Add support for output_files#618
niknetniko merged 24 commits intofiles-featuresfrom
output-files

Conversation

@niknetniko
Copy link
Member

@niknetniko niknetniko commented Feb 26, 2026

Implements the first part of #601, adding support for output_files:

tabs:
- tab: output_file
  contexts:
  - testcases:
    - expression: genereer('origineel_tekst.txt', 'text', 3)
      return: true
      output_files:
        - content: !path "files_tests/tekst1.txt"
          path: "text1.txt"
        - content: !path "files_tests/tekst2.txt"
          path: "text2.txt"
        - content: "Created using write mode.\n3\n"
          path: "text3.txt"

This is a bit special as internally it introduces the concept of an evaluator that returns multiple "channels" from a single evaluator.


Additionally, this PR introduced changes to the planning of a test suite execution to better support files. Specifically, a new execution will be started for:

  • Contexts that have the same input file with different content
    • Since, like stdin, files are prepared before execution, we need a new execution to have the same files with different content.
  • Output files in the same expected location
    • If we expect the student to write to the same file location, we must have a fresh execution to properly capture the file changes.

Note: the new file-related stuff is only available in the tabs/contexts/testcases naming in the DSL, not in the alternative schema, as I didn't want to put in the effort of changing those.

@niknetniko niknetniko self-assigned this Feb 26, 2026
@niknetniko niknetniko marked this pull request as ready for review February 28, 2026 14:48
Base automatically changed from input-files to files-features February 28, 2026 15:09
@niknetniko
Copy link
Member Author

I can't seem to get Copilot to review this (maybe something with rights), so I'll leave it up to someone else to request it.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements support for output_files in TESTed's test suite DSL (first part of issue #601). It extends the framework to allow multiple expected output files to be specified per test case, introduces conflict detection in the execution planner for both input and output files, and extracts the file oracle into its own module with multi-result support.

Changes:

  • New output_files DSL key and refactored FileOutputChannel to use a files: list[TextData] instead of the old expected_path/actual_path fields (with backward-compatible converters).
  • File oracle (tested/oracles/file.py) extracted from text.py, now returning a list[OracleResult] to report one result per file; _evaluate_channel in evaluation.py updated to iterate over all results.
  • Planning algorithm enhanced to detect and split on output file conflicts (same output path across contexts) and input file conflicts (same input path with different content).

Reviewed changes

Copilot reviewed 48 out of 48 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tested/testsuite.py FileOutputChannel refactored to files: list[TextData]; get_input_files/get_output_files methods added to Context
tested/oracles/file.py New file: extracted file oracle with multi-file support, returning list[OracleResult]
tested/oracles/text.py Removed evaluate_file function (moved to file.py)
tested/oracles/common.py Added channel_override field to OracleResult; updated Oracle/RawOracle types
tested/oracles/__init__.py Updated routing to use file.evaluate_file
tested/oracles/value.py Added FileOutputChannel handling in get_values for custom oracle use
tested/judge/planning.py New input/output file conflict detection in _flattened_contexts_to_units
tested/judge/evaluation.py Multi-result oracle support; _add_channel FileOutputChannel branch; link_files_message returns None when empty
tested/dsl/translate_parser.py New output_files key handling; refactored _convert_file_output_channel to support list/dict/legacy formats
tested/dsl/schema.json New output_files field, new fileDataFullyRequired definition, new format variants
tested/dsl/schema-strict.json Same schema updates as schema.json
tests/test_planning.py New comprehensive planning unit tests
tests/test_planning_sorting.py Extended sorting/deduplication tests
tests/test_oracles_builtin.py Updated file oracle tests for multi-result
tests/test_oracles_programmed.py New custom oracle tests for output files
tests/test_io_exercises.py New test_file_combinations integration test
tests/test_dsl_legacy.py New DSL parsing tests for both legacy and new output_files formats
tests/test_dsl_yaml.py Updated YAML DSL test assertions
tests/test_file_linking.py Corrected assertion for link_files_message returning None
tests/test_suite.py Updated FileOutputChannel deserialization assertions
tests/test_testsuite_legacy.py Updated legacy deserialization assertions
tests/exercises/time-2-code/* New exercise with input+output file combinations for all languages
tests/exercises/output-files-custom-oracle/* New exercise for custom oracle with output files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@niknetniko niknetniko merged commit 00174a5 into files-features Mar 5, 2026
7 checks passed
@niknetniko niknetniko deleted the output-files branch March 5, 2026 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants